package com.home.cop.sysinfo.controller;


import com.home.cop.base.BaseController;
import com.home.cop.sysinfo.model.Industry;
import com.home.cop.sysinfo.service.IndustryService;
import com.home.cop.system.RequiredAuth;
import com.home.cop.system.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api("企业行业相关")
@RequestMapping("/indu")
public class IndustryController extends BaseController {

    @Autowired
    private IndustryService industryService;

    @RequiredAuth
    @PostMapping("/list")
    @ApiOperation(value = "企业行业列表", notes = "企业行业列表")
    public Result list(){
        return Result.returnSuccess().setData(industryService.list(getPageNum(),getPageSize()));
    }

    @PostMapping("/delete")
    @ApiOperation(notes = "删除行业",value = "根据编号删除行业")
    @RequiredAuth
    @ApiImplicitParams({ @ApiImplicitParam(name = "indId", value = "行业id", required = true, dataType = "Integer", paramType = "query")
    })
    public Result deleteInd(@RequestParam("indId") Integer indId){
        industryService.delete(indId);
        return Result.returnSuccess().setMessage("删除成功");
    }

    @PostMapping("/add")
    @ApiOperation(notes = "新增行业",value = "新增行业信息")
    @RequiredAuth
    public Result addInd(@RequestBody Industry industry){
        industryService.insert(industry);
        return Result.returnSuccess().setMessage("新增成功！");
    }

    @PostMapping("/update")
    @ApiOperation(notes = "更新行业信息",value = "更新行业信息")
    @RequiredAuth
    public Result updateInd(@RequestBody Industry industry){
        industryService.update(industry);
        return Result.returnSuccess().setMessage("更新成功！");
    }
}
